﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FbKPI.Facade;
using FbKPI.Model;

namespace FBKPI.Forms
{
    public partial class SetupYearForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int ID = Convert.ToInt16(Request.QueryString["ID"]);
                int startYear = DateTime.Now.Year+1;

                for (int i = 4; i >0; i--)
                {
                    ddlEndYear.Items.Add(new ListItem((startYear-i).ToString(),(startYear-i).ToString()));
                    ddlStartYear.Items.Add(new ListItem((startYear - i).ToString(), (startYear - i).ToString()));
                }
                if (ID != 0)
                {
                    SetupYearFacade sf = new SetupYearFacade();
                    SetupYear SetupYear = sf.GetByID(ID);

                    if (SetupYear != null)
                    {

                        hfId.Value = SetupYear.YearID.ToString();
                        //ddlStartYear.Items.FindByValue(SetupYear.StartYear.ToString()).Selected = true;
                        ddlEndYear.Items.FindByValue(SetupYear.EndYear.ToString()).Selected = true;
                        
                    }
                }
               

                //if (txt_id.Text == "0") btn_delete.Visible = false;
            }
        }
    }
}